package sz.szsmk.citizencard.mvp.presenter;

import javax.inject.Inject;

import sz.szsmk.citizencard.model.network.bean.request.RegisterRequest;
import sz.szsmk.citizencard.model.network.bean.response.BaseBean;
import sz.szsmk.citizencard.model.network.bean.response.UserBean;
import sz.szsmk.citizencard.mvp.RegistBySmsMvpView;
import sz.szsmk.citizencard.mvp.dzsmkpresenter.AppBasePresenter;
import sz.szsmk.citizencard.retrofitrxjava.ErrorAction;
import sz.szsmk.citizencard.retrofitrxjava.NetworkDateSources;
import sz.szsmk.citizencard.retrofitrxjava.SubscribeResult;

/**
 * author : hyt
 * date : 2019/8/30
 * description :
 */
public class RegistBySmsPresenter extends AppBasePresenter<RegistBySmsMvpView> {

    private NetworkDateSources mNetworkDateSource;

    @Inject
    public RegistBySmsPresenter() {
        this.mNetworkDateSource = NetworkDateSources.getInstance();
    }

    public void registerAndLogin(RegisterRequest registerRequest){
        mNetworkDateSource.registerAndLogin(registerRequest, new SubscribeResult<UserBean>() {
            @Override
            protected void onOk(UserBean response) {
                getMvpView().registerAndLoginResult(response);
            }

            @Override
            protected void onFailure(UserBean response) {
                getMvpView().registerFail(response);
            }
        }, new ErrorAction() {
            @Override
            public void onCall(Throwable throwable) {

            }
        });
    }
}
